package com.keya.base.output;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.poi.ss.formula.functions.T;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultData implements Serializable {

    Integer code;
    String message;
    Object data;

    public static ResultData success() {
        ResultData resultData = new ResultData();
        resultData.setCode(RequestCode.SUCCESS.getCode());
        resultData.setMessage(RequestCode.SUCCESS.getMessage());
        return resultData;
    }

    public static ResultData success(Object data) {
        ResultData resultData = new ResultData();
        resultData.setCode(RequestCode.SUCCESS.getCode());
        resultData.setMessage(RequestCode.SUCCESS.getMessage());
        resultData.setData(data);
        return resultData;
    }

    public static ResultData success(Object data, String message) {
        ResultData resultData = new ResultData();
        resultData.setCode(RequestCode.SUCCESS.getCode());
        resultData.setMessage(message);
        resultData.setData(data);
        return resultData;
    }

    public static ResultData fail(int code, String message) {
        ResultData resultData = new ResultData();
        resultData.setCode(code);
        resultData.setMessage(message);
        return resultData;
    }

    public static ResultData fail(String message) {
        ResultData resultData = new ResultData();
        resultData.setCode(RequestCode.ERROR.getCode());
        resultData.setMessage(message);
        return resultData;
    }

}
